<template>
  <div class="agents-dividend-tx">
    <c-title :text="text"></c-title>
    <div class="head">
      <div class="img">
        <img :src="avatar" alt="">
      </div>
      <div class="head-right">
        <div class="between">
          <div class="nickname">{{ nickname }}</div>
          <div class="money">￥{{ all_amount }}</div>
        </div>
        <div class="between mt-13">
          <div class="member-id">{{ member_id }}</div>
          <div class="desc">累计佣金</div>
        </div>
      </div>
    </div>
    <div class="content">
      <van-tabs v-model="active" title-active-color="#F15353">
        <van-tab title="分红佣金">
          <div class="item" v-for="item in list" :key="item.id">
            <div class="between">
              <span class="item-id">ID：{{ item.id }}</span>
              <span class="item-monet">+￥{{ item.amounts }}</span>
            </div>
            <div class="between mt-24">
              <span class="item-ratio">分红比例：{{ item.ratio }}%</span>
              <span class="item-time">{{ item.created_at }}</span>
            </div>
          </div>
        </van-tab>
      </van-tabs>
    </div>
  </div>
</template>

<script>
import { scrollMixin } from "../../../utils/mixin";
export default {
  mixins: [scrollMixin],
  data() {
    return {
      active: 0,
      text: "",
      list: [],
      isLoadMore: true,
      page: 1,
      total_page: 0,
      nickname: "",
      avatar: "",
      member_id: "",
      all_amount: ""

    };
  },
  activated() {
    this.getData();
  },
  methods: {
    getData(page = 1) {
      $http.get("plugin.tx-agent-dividend.frontend.controllers.center.index", { page }, "").then(res => {
        if (res.result !== 1) {
          return this.$toast(res.msg);
        }
        this.isLoadMore = true;
        let { list, info } = res.data;
        this.page = list.current_page;
        this.total_page = list.last_page;
        this.text = info.plugin_name;
        if (page == 1) {
          this.list = list.data;
        } else {
          this.list = this.list.concat(list.data);
        }
        this.fun.setWXTitle(info.plugin_name)
        this.nickname = info.nickname;
        this.all_amount = info.all_amount;
        this.member_id = info.member_id;
        this.avatar = info.avatar;
      })
    },
    getMoreData() {
      this.isLoadMore = false;
      if (this.page >= this.total_page) {
        return;
      }
      let page = this.page + 1;
      this.getData(page);
    }
  }
};
</script>

<style scoped lang="scss">
.agents-dividend-tx ::v-deep .van-nav-bar {
  background-color: #F15353;
  border-bottom: 1px solid #F15353;
}

.agents-dividend-tx ::v-deep .van-nav-bar .van-icon {
  color: #fff;
}

.agents-dividend-tx ::v-deep .van-nav-bar__title {
  font-size: 1.0625rem;
  font-weight: 500;
  color: #FFFFFF;
}

::v-deep .van-tabs__line {
  background-color: #F15353;
  bottom: 20px;
}

.agents-dividend-tx ::v-deep .van-nav-bar .van-button {
  background-color: #F15353;
}

.agents-dividend-tx {
  .item-id {
    font-size: 0.8125rem;
    font-weight: 500;
    color: #353535;
  }

  .item-monet {
    font-size: 0.8125rem;
    font-weight: 500;
    color: #F15353;
  }

  .mt-24 {
    margin-top: 0.75rem;
  }

  .item-time {
    font-size: 0.8125rem;
    font-weight: normal;
    color: #545454;
  }

  .item-ratio {
    font-size: 0.8125rem;
    font-weight: normal;
    color: #545454;
  }

  .item {
    position: relative;
    padding: 0.9375rem 0.875rem;
    background: #FFFFFF;
    border-radius: 0.5rem;
    margin-bottom: 0.625rem;
  }

  .item:first-child::after {
    content: "";
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 1.5rem);
    height: 1px;
    background: #F2F2F2;
  }

  .img {
    width: 3.4375rem;
    height: 3.4375rem;
    border-radius: 100px;
    overflow: hidden;
    margin-right: 0.4063rem;
    flex-shrink: 0;

    img {
      width: 100%;
      height: 100%;

    }
  }

  .desc {
    font-size: 0.75rem;
    font-weight: 400;
    color: #FFFFFF;
  }

  .mt-13 {
    margin-top: 0.3438rem;
  }

  .member-id {
    background: #FFFFFF;
    border-radius: 0.625rem 0.625rem 0.625rem 0.625rem;
    padding: 0 0.625rem;
    box-sizing: border-box;
    font-size: 0.6875rem;
    font-weight: normal;
    color: #F15353;
    min-width: 3.2813rem;
    height: 1.25rem;
    line-height: 1.25rem;
  }

  .money {
    font-size: 1rem;
    font-weight: normal;
    color: #FFFFFF;
    margin-bottom: -0.2813rem;
  }

  .nickname {
    font-size: 1rem;
    font-weight: normal;
    color: #FFFFFF;
  }

  .between {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .head-right {
    flex: 1;
  }

  .head {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #F15353;
    padding: 1.0625rem 0.625rem 0.9375rem 1.0313rem;
  }

  .content {
    padding: 0.625rem 0.75rem;
  }

}
</style>
